<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>系统设置</title>

    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/yzl.css"/>

</head>
<body>
<div class="header">
    <div id="blank" v-back.tapmode class="back"></div>
    <span class="title">系统设置</span>
</div>
<div id="app" class="main-container">
    <div class="row-container">
        <a v-myclick="clearCache" class="row" v-row-active.tapmode>
            <span>清除缓存</span>
            <img class="row-arrow" v-src="'../../image/arrow_right_grey.png'">
            <span style="color:#999999" v-cloak>{{cacheSize}}</span>
        </a>
        <!-- <a v-open-win v-row-active.tapmode vurl="modifyPwd" class="row">
            <span>提现密码设置</span>
            <img class="row-arrow" v-src="'../../image/arrow_right_grey.png'">
            <span style="color:#999999" v-cloak>{{withdraw_password_settled == 1 ? '已设置' : '未设置'}}</span>
        </a> -->
        <a v-open-win v-row-active.tapmode vurl="feedback" class="row">
            <span>留言反馈</span>
            <img class="row-arrow" v-src="'../../image/arrow_right_grey.png'">
        </a>
        <!-- <a class="row" v-myclick="initMeiQia" v-row-active.tapmode> -->
            <!-- <span>在线客服</span> -->
            <!-- <img class="row-arrow" v-src="'../../image/arrow_right_grey.png'"> -->
            <!-- <span v-show="unreadMessageCount > 0" class="hasNotRead-icon" style="margin-top:13px;" -->
                  <!-- v-cloak>{{unreadMessageCount}}</span> -->
        <!-- </a> -->
        <a v-open-win v-row-active.tapmode vurl="aboutUs" class="row">
        <!-- <a v-myclick="openAbout_us" class="row"> -->
            <span>关于我们</span>
            <img class="row-arrow" v-src="'../../image/arrow_right_grey.png'">
        </a>
    </div>
    <div class="row-container" style="margin-top:20px;">
        <div class="row" v-myclick="logout" v-row-active.tapmode
             style="margin:0 auto;width:85%;border-radius:4px;text-align:center;height:50px;background:#33375E;color:#ffffff;line-height:50px;font-size:16px;">
            退出登录
        </div>
    </div>
</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script>

    var mq,
        vm,
        talkingData;

    var withdraw_password_settled;
    var aliTradePlus;

    var user;

    apiready = function () {
        setBSImg();
        new Vue({
            el: '#blank'
        });
        talkingData = api.require('talkingData');
        aliTradePlus = api.require('webViewModule');
        mq = api.require('meiQia');
        user = getPrefs('token') ? JSON.parse(getPrefs('user')) : null;
        withdraw_password_settled = user ? user.withdraw_password_settled : 0;
        initApp();
        api.parseTapmode();
        addListeners();
    };

    function initApp() {
        vm = new Vue({
            el: '#app',
            data: {
                cacheSize: "",
                unreadMessageCount: 0,
                withdraw_password_settled: withdraw_password_settled
            },
            methods: {
                getCacheSize: function () {
                    var _size = api.getCacheSize({sync: true});
                    var size = ((_size / 1024) / 1024).toFixed(1);
                    this.cacheSize = size + 'MB';
                },
                clearCache: function () {
                    showProgress();
                    api.clearCache(
                        function () {
                            vm.cacheSize = '0.0MB';
                            api.toast({
                                msg: '缓存清除成功',
                            });
                            hideProgress();
                        }
                    );
                },
                initMeiQia: function () {
                    showMeiQia();
                },
                logout: function () {
                    api.confirm({
                        title: '提示',
                        msg: '确定退出登录吗',
                        buttons: ['确定', '取消']
                    }, function (ret) {
                        if (ret.buttonIndex == 1) {
                            closeWin('settings');
                            closeWin('index');
                            removePrefs('token');
                            removePrefs('imtoken');
                            removePrefs('portrait');
                            removePrefs('username');
                            removePrefs('phone');
                            removePrefs('portrait');
                            removePrefs('member_id');
                            removePrefs('member_im_id');
                            api.openWin({
                              reload : true,
                              name : 'login',
                              url : '../login/login.html',
                              vScrollBarEnabled : false,
                              slidBackEnabled : false
                            });
                            // openWin('../login/login', {from: api.winName});
                        }
                    });
                },
                openAbout_us: function () {
                    openWin('../home/browser', {url: URL.about_us});
                }
            },
            created: function () {
                this.getCacheSize();
//                mq.getUnreadMessageCount(function (result) {
//                    vm.unreadMessageCount = result['count'];
//                });
            }
        });
    }

    function addListeners() {
        api.addEventListener({
            name: 'settleWithdrawPassword'
        }, function () {
            vm.withdraw_password_settled = 1;
        });

        api.addEventListener({
            name: 'viewappear'
        }, function () {
            onPageStart();
        });

        api.addEventListener({
            name: 'viewdisappear'
        }, function () {
            onPageEnd();
        });

        api.addEventListener({
            name: 'keyback'
        }, function () {
            onPageEnd();
            api.closeWin();
        });
    }


</script>
</html>
